// 导入用户集合
const { Category } = require('../../../model/category');
const { Banner } = require('../../../model/banner')
const { Goods } = require('../../../model/goods')
const { goodsState } = require('../../../enum/state')

module.exports = async (req, res) => {
  const cateList = await Category.find().limit(7).sort({ _id: -1 })
  cateList.push({
    name: '更多',
    icon: 'https://cdn.uviewui.com/uview/menu/2.png'
  })
  const bannerList = await Banner.find({ show: true }).sort({ sort: 1 }).limit(6)
  // const goodsList = await Goods.find({state: goodsState.published}).sort({_id: -1})
  const goodsList = await Goods.find({ state: goodsState['published'], show: true }).sort({ sort: 1 }).limit(10)
  res.json({
    data: {
      cateList,
      bannerList,
      goodsList
    }
  })
}